﻿using System;

namespace DNT.RavenQA.Core.Extensions
{
    public static class ObjectExtensions
    {
        public static Boolean IsNull<T>(this T obj) where T : class
        {
            return obj == null;
        }

        public static Boolean IsNotNull<T>(this T obj) where T : class
        {
            return obj != null;
        }

        public static void EnsureIsNull<T>(this T obj, String parameterName = "") where T : class
        {
            if (obj.IsNotNull())
                throw new ArgumentException(parameterName.IsNullOrWhiteSpace() ? "no-name supplied" : parameterName);
        }

        public static void EnsureIsNotNull<T>(this T obj, String parameterName = "") where T : class
        {
            if (obj.IsNull())
                throw new ArgumentNullException(parameterName.IsNullOrWhiteSpace() ? "no-name supplied" : parameterName);
        }
    }
}